<?php
namespace Api\Controller;
use Think\Controller;
class PassWordController extends Controller {
  public function forgetPassSubmit(){
          $utypearray=array('user','doctor');
          $phone    = I('phone');//手机号码
          $code     = I('phonecode');//手机验证码
          $password = I('password');//用户密码
          $utype    = I('utype');//user:用户 doctor:医生 
          $where['phone']=$phone;
          if(!in_array($utype, $utypearray)){
            $returninfo='请填写有效的用户utype类型!';
            EchoData($uinfo,0,105,$returninfo,0);
          }
          if(empty($password)){
            $returninfo='密码不能为空!';
            EchoData($uinfo,0,109,$returninfo,0);
          }
          $data['password']=md5($password);
          if(!verPhone($phone)){
            EchoData($uid,0,107,'手机号码格式错误',0);
          }
          if(empty($code)){
            EchoData($uid,0,110,'验证码不能为空',0);
          }

          $PhoneCode=D('PhoneCode')->verPhoneCode($phone,$code,'forgetpass');
          if(!$PhoneCode){
            EchoData($uid,0,102,'验证码错误',0);
          }else{
           if($utype=='user'){
           


            $Uppass=D('User')->UpToPhone($phone,$data);
            $fdInfo=fd('User',$where);
            $UInfo =D('User')->toIdGetUserInfo($fdInfo['id']);
            $refont='用户密码';
          }elseif($utype=='doctor'){
            $Uppass=D('Doctor')->UpToPhone($phone,$data);
            $fdInfo=fd('Doctor',$where);
            $UInfo =D('Doctor')->toIdGetDoctorInfo($fdInfo['id']);
            $refont='医生密码';
          }
          if($Uppass){
            $reinfo='修改'.$refont.'成功';
            EchoData($UInfo,1,100,$reinfo,0);
          }else{
            $reinfo='修改'.$refont.'失败';
            EchoData($uid,0,101,$reinfo,0);
          }
        }
      }
    }